<!-- S search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  labelFlex="80px"
  (onSearch)="queryResetData($event)"
  (onReset)="queryResetData($event)"
>
</app-search-bar>
<!-- E search -->

<nz-card class="m-t-4">
  <div class="opera-wrap">
    <button
      nz-button
      nzType="primary"
      routerLink="/promotionshare/game-operate-notice-edit"
      [queryParams]="{type: 0}"
    >新增</button>
  </div>

  <div class="pagination-wrap-position p-t-15">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzWidth="80px">ID</th>
          <th nzAlign="center" nzWidth="200px">标题</th>
          <th nzAlign="center" nzWidth="160px">副标题</th>
          <th nzAlign="center" nzWidth="170px">开始时间</th>
          <th nzAlign="center" nzWidth="120px">状态</th>
          <th nzAlign="center" nzWidth="170px">创建时间</th>
          <th nzAlign="center" nzWidth="180px" nzRight>操作</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- ID -->
          <td nzAlign="center">{{ data.id }}</td>
          <!-- 标题 -->
          <td nzAlign="center">{{ data.title || '-' }}</td>
          <!-- 副标题 -->
          <td nzAlign="center">{{ data.subheading || '-' }}</td>
          <!-- 开始时间 -->
          <td nzAlign="center">{{ data.beginTime || '-' }}</td>
          <!-- 状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.state | gameActNoticeStatus: 'color'}">
              {{ data.state | gameActNoticeStatus: 'label' }}
            </span>
          </td>
          <!-- 创建时间 -->
          <td nzAlign="center">{{ data.createTime || '-' }}</td>
          <!-- 操作 -->
          <td nzAlign="center" nzRight>
            <button
              nz-button
              nzType="link"
              nzSize="small"
              routerLink="/promotionshare/game-operate-notice-edit"
              [queryParams]="{type: 2, id: data.id}"
            >查看</button>

            <button
              *ngIf="[0, 1].includes(data.state)"
              nz-button
              nzType="link"
              nzSize="small"
              routerLink="/promotionshare/game-operate-notice-edit"
              [queryParams]="{type: 1, id: data.id}"
            >编辑</button>

            <button
              *ngIf="[0].includes(data.state)"
              style="color: #87d068;"
              nz-button
              nzType="link"
              nzSize="small"
              nz-popconfirm
              nzPopconfirmTitle="确认发送?"
              (nzOnConfirm)="sendItemData(data)"
            >发送</button>

            <button
              *ngIf="[1].includes(data.state)"
              nz-button
              nzType="link"
              nzSize="small"
              nz-popconfirm
              nzPopconfirmTitle="确认撤回?"
              (nzOnConfirm)="withdrawItemData(data)"
            >撤回</button>

            <button
              *ngIf="[0].includes(data.state)"
              nz-button
              nzType="link"
              nzSize="small"
              nzDanger
              nz-popconfirm
              nzPopconfirmTitle="确认删除?"
              (nzOnConfirm)="deleteItemData(data)"
            >删除</button>
          </td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>